import { bill } from '../../../api.js'
var app = getApp(); //获取App内部的信息
Page({

  /**
   * 页面的初始数据
   */
  data: {
    accountBalance:'',
    accountNotBalance:'',
    accounrNum:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    bill({ token: app.globalData.token }).then(res => {
      if (res.data.code == 666) {
        that.setData({
          accountBalance: res.data.data.accountBalance,
          accountNotBalance: res.data.data.accountNotBalance,
          accounrNum: res.data.data.accounrNum
        })
      } else if (res.data.code == 111111) {
        wx.showToast({
          title: '登录失效，请重新登录',
          icon: 'none',
        })
        setTimeout(function () {
          wx.reLaunch({
            url: '/pages/user/login/login',
          })
        }, 1500)
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },
  detailed:function(){
    wx.navigateTo({
      url: '/pages/user/bill/detailed/detailed',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  putForward:function(){
    var num = this.data.accountBalance
    wx.navigateTo({
      url: '/pages/user/bill/putForward/putForward?money='+num,
    })
  }
})